<template>
  <div class="page">
    <!-- <iframe src="http://192.168.100.50:8899/" frameborder="0"></iframe> -->
    <!-- <micro-app
        id="template"
        name="template"
        url="http://localhost:51740"
        iframe
      ></micro-app> -->
    <!-- <micro-app
      id="template"
      name="template"
      url="http://localhost:51740/#/knowledgeBase/index"
      iframe
    ></micro-app> -->
    <micro-app id="template" name="template" :url="url" iframe />
  </div>
</template>

<script>
import { message } from 'ant-design-vue'
import microApp from '@micro-zoe/micro-app'
import store from '@/store'
import { setTheme } from '@/store/modules/user'
import bus from '@/utils/bus'
export default {
  data() {
    return {
      url: ''
    }
  },
  computed: {
    d() {
      return {
        theme: store.userStore.theme,
        color: {
          ...store.userStore.color
        },
        setTheme: setTheme,
        platformId: store.userStore.platformId,
        token: store.userStore.token
      }
    }
  },
  watch: {
    d: {
      handler(val) {
        bus.emit('sendData', val)
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    LoginOut(data) {
      message.error('您的登录信息已过期，请重新登录!')
      store.userStore.LoginOut()
    }
  },
  mounted() {
    microApp.addDataListener('template', this.LoginOut)
    this.url = store.userStore.templateUrl + '/#/knowledgeBase/index'
  },
  unmounted() {
    microApp.removeDataListener('template', this.LoginOut)
  }
}
</script>

<style lang="less" scoped>
.page {
  height: calc(100% - 2px);
  padding: 0;
  overflow: hidden;
}
</style>
